import Vue from 'vue'
import VueRouter from 'vue-router'

// 路由
import Login from "@/components/user/Login";
import Home from "@/components/user/Home";
import Jurisdiction from "@/components/Meun/Jurisdiction";
import Merchandise from "@/components/Meun/Merchandise";
import Indent from "@/components/Meun/Indent";
import System from "@/components/Meun/System";
import User from "@/components/Meun/User";


Vue.use(VueRouter)


const router = new VueRouter({
    routes: [
        {path: '/', redirect: '/login'},

        {path: '/login', component: Login},
        {
            path: '/home', component: Home,
            children: [
                {path: 'user1', component: User},
                {path: 'jur2', component: Jurisdiction},
                {path: 'mer3', component: Merchandise},
                {path: 'indent4', component: Indent},
                {path: 'sys5', component: System},
            ]
        },
    ]
})

// 全局创建导航守卫
router.beforeEach(function (to, from, next) {
    // // console.log(to.path)
    // const token = window.localStorage.getItem('token')
    // if (token) {
    //     next();
    // }
    // if(to.path==="/Home"){
    //     next('/login');
    //     alert("权限不够")
    // }else {
    //     next();
    // }
    next()
})

export default router
